package com.bookmarket.test;

import com.bookmarket.entity.Btype;
import com.bookmarket.entity.Custom;
import com.bookmarket.entity.Order_Book;
import com.bookmarket.service.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-mybatis.xml")
public class HJHDemo {

    @Resource
    private HJHStageLoginAndRegService hJHStageLoginAndRegService;

    @Resource
    private HJHActiveService hJHActiveService;

    @Resource
    private HJHStatisticalService hJHStatisticalService;

    @Resource
    private HJHLoginService hJHLoginServices;

    @Resource
    private HJHRoleService roleService;

    @Resource
    private HJHShowService hJHShowService;

    @Test
    public void test1(){
        Custom custom1=new Custom();
        custom1.setName("sss");
        custom1.setPass("sss");
        Custom custom=hJHStageLoginAndRegService.CustomLogin(custom1);
        System.out.println(custom.getName());
    }


    @Test
    public void test2(){
        List<Btype> list=hJHActiveService.findBtype();
        System.out.println(list.get(1).getType());
    }

    @Test
    public void test3(){
        List<Btype> list=hJHStatisticalService.findAllBtype();
        for (Btype b:list) {
            System.out.println(b.getId()+":::"+b.getType());
        }
    }

    @Test
    public void test4(){
        List<Order_Book> list=hJHStatisticalService.findAllOrder_Book();
        for (Order_Book ob:list) {
            System.out.println(ob.getAmount()+"::"+ob.getBook().getPrice()+"::"+ob.getBook().getStype().getBtype().getType());
        }
    }

    @Test
    public void test5(){
        Custom custom=new Custom();
        custom.setName("1");
        custom.setPass("1");
        custom.setRealName("aa");
        custom.setEmail("84@qq.com");
        custom.setPhone("13033778887");
        custom.setSex(0);
        hJHStageLoginAndRegService.CustomRegist(custom);
    }

    @Test
    public void test6(){
        int num=hJHLoginServices.findRole_id("1");
        System.out.println(num);
        String role=hJHLoginServices.findRole(num);
        System.out.println(role);
    }


    @Test
    public void test7(){
        roleService.ChangePass(4,"123");
    }

    @Test
    public void test8(){
        int num=hJHShowService.ShowSales();
        System.out.println(num);
    }

    @Test
    public void test9(){
        /*List<Book> list=hJHActiveService.findAllBook(1);
        for (Book b:list) {
            System.out.println(b.getPicture());
        }*/
    }


    public HJHShowService gethJHShowService() {
        return hJHShowService;
    }

    public void sethJHShowService(HJHShowService hJHShowService) {
        this.hJHShowService = hJHShowService;
    }

    public HJHRoleService getRoleService() {
        return roleService;
    }

    public void setRoleService(HJHRoleService roleService) {
        this.roleService = roleService;
    }

    public HJHStatisticalService gethJHStatisticalService() {
        return hJHStatisticalService;
    }

    public void sethJHStatisticalService(HJHStatisticalService hJHStatisticalService) {
        this.hJHStatisticalService = hJHStatisticalService;
    }

    public HJHLoginService gethJHLoginServices() {
        return hJHLoginServices;
    }

    public void sethJHLoginServices(HJHLoginService hJHLoginServices) {
        this.hJHLoginServices = hJHLoginServices;
    }

    public HJHActiveService gethJHActiveService() {
        return hJHActiveService;
    }

    public void sethJHActiveService(HJHActiveService hJHActiveService) {
        this.hJHActiveService = hJHActiveService;
    }

    public HJHStageLoginAndRegService gethJHStageLoginAndRegService() {
        return hJHStageLoginAndRegService;
    }

    public void sethJHStageLoginAndRegService(HJHStageLoginAndRegService hJHStageLoginAndRegService) {
        this.hJHStageLoginAndRegService = hJHStageLoginAndRegService;
    }
}